package com.eascs.web.o2o.web.sso;

import javax.inject.Inject;

import org.springframework.stereotype.Repository;

import com.eascs.app.dao.JdbcSession;
import com.eascs.web.sso.User;

@Repository
public class EaSsoDao {
	@Inject
	private JdbcSession jdbcSessionOracle;

	public <T extends User> T getUserByAccount(String loginName, Class<T> type) {
		String sql = "select h.EMPLOYEENO as no,h.EMPLOYEECODE as code,h.EMPLOYEENAMECN as cname,h.EMAIL as email,h.MOBILE as mobile,h.EMPLOYEEACCOUNT as account,h.OPERATIONDEPT as org from eadb.HR_EMPLOYEE h where h.EMPLOYEEACCOUNT = ?";
		return this.jdbcSessionOracle.findEntity(sql, type, loginName);
	}
	
	public <T extends User> T getUserByNo(String userNo, Class<T> type) {
		String sql = "select e.employee_no as no,e.employee_code as code,e.employee_namecn as cname,e.email as email, e.province_code as org, "
				+ " e.mobile as mobile,e.employee_account as account, o.nodenamecn as nodenamecn,e.is_dimission as status from o2o_employee e,hr_organ o "
				+ " where e.node_id = o.nodeno and e.employee_no = ? ";
		return this.jdbcSessionOracle.findEntity(sql, type, userNo);
	}
}
